
import org.apache.commons.beanutils.PropertyUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;

@Service
public class DmsMachineManagementServiceImpl implements DmsMachineManagementService  {

    @Resource
    private DmsMachineManagementMapper dmsMachineManagementMapper;

    /**
     * 获取 DmsMachineManagement 分页列表
     */
    @Transactional
    public IPage getDmsMachineManagementPagination( PaginationVo paginationVo, DmsMachineManagementQuery dmsMachineManagementQuery ) throws Exception {

        IPage page = new Page( paginationVo.getPageIndex(), paginationVo.getPageSize() );
        LambdaQueryWrapper<DmsMachineManagementEntity> lqs = new LambdaQueryWrapper();
        dmsMachineManagementMapper.selectPage(page, lqs);

        List<DmsMachineManagementEntity> record = page.getRecords();
        if( !ObjectUtil.isNotEmptyList(record)){
            return page;
        }
        return null;
    }


    /**
     * 获取 DmsMachineManagement 所有数据
     *
    */
    @Transactional
    public List<DmsMachineManagementEntity> getDmsMachineManagementAllList( DmsMachineManagementQuery dmsMachineManagementQuery ) throws Exception {

        LambdaQueryWrapper<DmsMachineManagementEntity> lqs = new LambdaQueryWrapper();
        List<DmsMachineManagementEntity> list = dmsMachineManagementMapper.selectList(lqs);
        return list;
    }


    /**
     * 获取 DmsMachineManagement 详情
    */
    @Transactional
    public DmsMachineManagementEntity getDmsMachineManagementDetail( Long id) throws Exception {

        DmsMachineManagementEntity dmsMachineManagement = dmsMachineManagementMapper.selectById(id);
        return dmsMachineManagement;
    }


    /**
     * 新增 DmsMachineManagement
     * */
    @Transactional
    public void addDmsMachineManagement(DmsMachineManagementVo dmsMachineManagementVo) throws Exception {

        DmsMachineManagementEntity dmsMachineManagement = new DmsMachineManagementEntity();
        ReflectionCopy.copyProperties( dmsMachineManagement, dmsMachineManagementVo );
        dmsMachineManagementMapper.insert(dmsMachineManagement);
        return;
    }


    /**
     * 更新 DmsMachineManagement
     * */
    @Transactional
    public void updateDmsMachineManagement( DmsMachineManagementVo dmsMachineManagementVo) throws Exception {

        if( dmsMachineManagementVo.getId() == null ){
            throw GlobalException.gen(10021, "id不存在");
        }
        DmsMachineManagementEntity dmsMachineManagement = new DmsMachineManagementEntity();
        ReflectionCopy.copyProperties( dmsMachineManagement, dmsMachineManagementVo );
        dmsMachineManagementMapper.updateById(dmsMachineManagement);
        return;
    }

    /**
     * 删除 DmsMachineManagement
     * */
    @Transactional
    public void batchRemoveDmsMachineManagement( List<Long> ids ) throws Exception {


        if( !ObjectUtil.isNotEmptyList(ids) ){
            throw GlobalException.gen(10011, "要删除的id不存在");
        }
        dmsMachineManagementMapper.deleteBatchIds(ids);
    }

}

      